package com.example.userservice.controller;


import com.example.userservice.service.UserInfoBeautyService;
import com.example.userservice.service.UserInfoService;
import org.example.annotation.GlobalInteceptor;
import org.example.controller.ABaseController;
import org.example.entity.po.UserInfoBeauty;
import org.example.entity.query.UserInfoBeautyQuery;
import org.example.entity.vo.PaginationResultVO;
import org.example.entity.vo.ResponseVO;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description
 * @Author susu
 * @Date 2024/9/8
 */
@RestController
@RequestMapping("/admin")
public class AdminBeautyController extends ABaseController {
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserInfoBeautyService userInfoBeautyService;

    @RequestMapping("/loadBeautyAccountList")
    @GlobalInteceptor(checkAdmin = true)
    public ResponseVO loadBeautyAccountList(UserInfoBeautyQuery query){
        query.setOrderBy("id desc");
        PaginationResultVO<UserInfoBeauty> listByPage = userInfoBeautyService.findListByPage(query);
        return getSuccessResponseVO(listByPage);
    }

    @RequestMapping("/saveBeautAccount")
    @GlobalInteceptor(checkAdmin = true)
    public ResponseVO saveBeautAccount(UserInfoBeauty beauty){
        userInfoBeautyService.saveOrUpdateAccount(beauty);
        return getSuccessResponseVO(null);
    }

    @RequestMapping("/delBeautAccount")
    @GlobalInteceptor(checkAdmin = true)
    public ResponseVO delBeautAccount(Integer id){
        userInfoBeautyService.deleteUserInfoBeautyById(id);
        return getSuccessResponseVO(null);
    }
}
